package com.personal.kousuan.factory;

import java.util.HashMap;
import java.util.Map;

import com.personal.kousuan.random.BuJieWeiRandomGenerator;
import com.personal.kousuan.random.BuJinWeiRandomGenerator;
import com.personal.kousuan.random.JieWeiRandomGenerator;
import com.personal.kousuan.random.JinWeiRandomGenerator;
import com.personal.kousuan.random.RandomGenerator;

public class RandomGeneratorFactory {

	private static RandomGeneratorFactory instance;
	private RandomGeneratorFactory(){}
	public static final String JINWEI_RANDOM_GENERATOR = "JinWeiRandomGenerator";
	public static final String BUJINWEI_RANDOM_GENERATOR = "BuJinWeiRandomGenerator";
	public static final String JIEWEI_RANDOM_GENERATOR = "JieWeiRandomGenerator";
	public static final String BUJIEWEI_RANDOM_GENERATOR = "BuJieWeiRandomGenerator";
	
	private static Map<String,RandomGenerator> randomGenerateMap = new HashMap<String,RandomGenerator>();
	static{
		randomGenerateMap.put(JINWEI_RANDOM_GENERATOR, new JinWeiRandomGenerator());
		randomGenerateMap.put(BUJINWEI_RANDOM_GENERATOR, new BuJinWeiRandomGenerator());
		randomGenerateMap.put(JIEWEI_RANDOM_GENERATOR, new JieWeiRandomGenerator());
		randomGenerateMap.put(BUJIEWEI_RANDOM_GENERATOR, new BuJieWeiRandomGenerator());
	}
	public static RandomGeneratorFactory getInstance(){
		if(instance == null){
			instance = new RandomGeneratorFactory();
		}
		return instance;
	}
	
	public RandomGenerator getRandomGenerator(String key){
		return randomGenerateMap.get(key);
	}
}
